
#ifndef H_C_MAP_H
#define H_C_MAP_H

#include "ctypes.h"
#include "cpair.h"
#include "crbtree.h"

typedef struct tagSMap{	
	EContainerType  eContainerType;
	SStlcType       stStlcType;   	
	SPair           stPair;
	SRbTree         stMapTree;
}SMap, *PSMap;

#ifdef __cplusplus
extern "C" {
#endif

#define MapCreate( keytype, valuetype )\
	    StlcMapCreate( sizeof( keytype ), #keytype,	sizeof( valuetype ), #valuetype )
#define MapInit( pmap, keycmpfunc )\
	    StlcMapInit( pmap, keycmpfunc )
#define MapBegin( pmap )\
	    StlcMapBegin( (pmap) )
#define MapEnd( pmap )\
	    StlcMapEnd( (pmap) )
#define MapInsert( pmap, pkey, pvalue )\
	    StlcMapInsert( (pmap), (pkey), (pvalue) )
#define MapFind( pmap, key )\
	    StlcMapFind( pmap, key )
#define MapFindPos( pmap, key )\
	    StlcMapFindPos( pmap, key )
#define MapErase( pmap, key )\
    	StlcMapErase( pmap, key )
#define MapClear( pmap )\
	    StlcMapClear( pmap )
#define MapDestroy( pmap )\
	    StlcMapDestroy( pmap )


STLCDLL_EXPORTS SMap      StlcMapCreate( size_t a_szKeyTypeSize, const char* a_pcKeyTypeName, size_t a_szValueTypeSize, const char* a_pcValueTypeName );
STLCDLL_EXPORTS void      StlcMapInit( PSMap a_pstMap, PFCompare a_pfnCompare );	
STLCDLL_EXPORTS void      StlcMapInitCopy( PSMap a_pstMapDest, const SMap* a_pstMapSrc );	
STLCDLL_EXPORTS void      StlcMapInitCopyRange( PSMap a_pstMapDest, const SIterator a_stIterBegin, const SIterator a_stIterEnd );

STLCDLL_EXPORTS bool      StlcMapSameType( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS size_t    StlcMapSize( const SMap* a_pstMap );
STLCDLL_EXPORTS size_t    StlcMapMaxSize( const SMap* a_pstMap );
STLCDLL_EXPORTS bool      StlcMapEmpty( const SMap* a_pstMap );

STLCDLL_EXPORTS bool      StlcMapEqual( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS bool      StlcMapNotEqual( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS bool      StlcMapLess( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS bool      StlcMapGreat( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS bool      StlcMapLessEqual( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );
STLCDLL_EXPORTS bool      StlcMapGreatEqual( const SMap* a_pstMapFirst, const SMap* a_pstMapSecond );

STLCDLL_EXPORTS SIterator StlcMapBegin( const SMap* a_pstMap );
STLCDLL_EXPORTS SIterator StlcMapEnd( const SMap* a_pstMap );

STLCDLL_EXPORTS SIterator StlcMapInsert( PSMap a_pstMap, const void* a_pKey, const void* a_pValue );
STLCDLL_EXPORTS SIterator StlcMapInsertPair( PSMap a_pstMap, const SPair* a_pstPair );
STLCDLL_EXPORTS void*     StlcMapFind( const SMap* a_pstMap, ... );
STLCDLL_EXPORTS SIterator StlcMapFindPos( const SMap* a_pstMap, ... );
STLCDLL_EXPORTS SIterator StlcMapErase( PSMap a_pstMap, ... );
STLCDLL_EXPORTS SIterator StlcMapErasePos( PSMap a_pstMap, SIterator a_stIterator );

STLCDLL_EXPORTS void      StlcMapClear( PSMap a_pstMap );
STLCDLL_EXPORTS void      StlcMapDestroy( PSMap a_pstMap );	
		
STLCDLL_EXPORTS SIterator   StlcMapIteratorCreate(void);
STLCDLL_EXPORTS bool        StlcMapIteratorBelongTo( const SMap* a_pstMap, const SIterator a_stIterator );
STLCDLL_EXPORTS bool        StlcMapIteratorEqual( const SMap* a_pstMap, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
STLCDLL_EXPORTS void        StlcMapIteratorGetValue( const SMap* a_pstMap, const SIterator a_stIterator, void* a_pValue );
STLCDLL_EXPORTS void        StlcMapIteratorGetPair( const SMap* a_pstMap, const SIterator a_stIterator, PSPair a_pstPair );
STLCDLL_EXPORTS const void* StlcMapIteratorGetPointer( const SMap* a_pstMap, const SIterator a_stIterator ); 
STLCDLL_EXPORTS void        StlcMapIteratorNext( const SMap* a_pstMap, PSIterator a_pstIterator );
STLCDLL_EXPORTS void        StlcMapIteratorPrev( const SMap* a_pstMap, PSIterator a_pstIterator );
STLCDLL_EXPORTS void        StlcMapIteratorNextN( const SMap* a_pstMap, PSIterator a_pstIterator, int a_nStep );
STLCDLL_EXPORTS void        StlcMapIteratorPrevN( const SMap* a_pstMap, PSIterator a_pstIterator, int a_nStep );
STLCDLL_EXPORTS int         StlcMapIteratorDistance( const SMap* a_pstMap, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
STLCDLL_EXPORTS bool        StlcMapIteratorBefore( const SIterator a_stIterFirst, const SIterator a_stIterSecond );

#ifdef __cplusplus
}
#endif

#endif